'use strict';
const path = require('path');
const fs = require('fs');

module.exports = appInfo => {
  const config = {
    name: appInfo.name,
    env: appInfo.env,
    csrf: false,
  };

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1513320467981_2709';

  config.static = {
    prefix: '/public/',
    dir: path.join(appInfo.baseDir, 'app/public'),
    dynamic: true,
    preload: false,
    buffer: false,
    maxFiles: 1000,
  };

  // add your config here
  config.middleware = [];

  config.view = {
    defaultViewEngine: 'nunjucks',
    mapping: {
      '.tpl': 'nunjucks',
    },
  };

  config.mongoose = {
    url: 'mongodb://localhost/test',
    options: { },
  };

  // config.coreMiddleware = [
  // 'meta',
  // 'siteFile',
  // 'notfound',
  // 'bodyParser',
  // 'overrideMethod',
  // ];
  config.notfound = {
    pageUrl: 'not found page',
  };
  config.siteFile = {
    '/favicon.ico': fs.readFileSync(path.join(appInfo.baseDir, 'app/public/favicon.png')),
  };

  return config;
};
